package com.googlecode.shapeline.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.googlecode.shapeline.common.Consts;
import com.googlecode.shapeline.core.User;

public class IndexAction extends DispatchAction {
	//private static final org.apache.log4j.Logger log = org.apache.log4j.LogManager.getLogger(IndexAction.class);
	
	public ActionForward execute(
			ActionMapping mapping, 
			ActionForm form, 
			HttpServletRequest request,
			HttpServletResponse response)
			throws IOException, ServletException {
		
		User loginUser = (User)request.getSession(true).getAttribute(Consts.SESSION_KEY_LOGIN);
		
		if (loginUser == null) {
			return mapping.findForward("login");
		}
		else {
			//request.setAttribute("loginUser", loginUser);
			return mapping.findForward("home");
		}
	}
}
